#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
#define MAX(A, B) ((A) > (B) ? (A) : (B))
class Solution {
public:
  long long maxSum(vector<int> &nums, int m, int k) {
    unordered_map<int, int> map;
    int max = INT_MIN;
    int count = 0;
    int diff = 0;
    int size = nums.size();
    for (int right = 0, left = right - k + 1; right < size; right++, left++) {
      count += nums[right];
      if (map[nums[right]] == 0) {
        printf("%d\n", __LINE__);
        diff++;
      }
      map[nums[right]]++;
      if (left > 0) {
        printf("%d\n", __LINE__);
        count -= nums[left];
        if (map[nums[left]] == 1) {
          printf("%d\n", __LINE__);
          diff--;
        }
        if (map[nums[left]] == 2) {
          printf("%d\n", __LINE__);
          diff++;
        }
        printf("%d\n", __LINE__);
        map[nums[left]]--;
      }
      if (left >= 0 && diff >= m) {
        printf("%d,%d,%d\t", right, left, diff);
        max = MAX(max, count);
        printf("%d\n", max);
      }
    }
    return max;
  }
};

int main(int argc, char *argv[]) {
  Solution ans;
  std::vector<int> vec = {1, 2, 1, 2, 1, 2, 1};
  int m = 3;
  int k = 3;
  ans.maxSum(vec, m, k);
  return 0;
}
